import { getAuthCode } from '@/services/global/base';
import { AuthSdk } from './authsdk';

export const TOKEN_KEY = 'AuthorizationToken';

// 记录上次访问页面
export const FROM_URL_KEY = 'FROM_URL';

export function getToken(): string {
  const token = localStorage.getItem(TOKEN_KEY) || '';
  return token;
}

export function setToken(token: string) {
  return localStorage.setItem(TOKEN_KEY, token);
}

export const authSdk = new AuthSdk(async () => {
  // const { data } = await getAuthCode();
  const userType: any = localStorage.getItem('userType');
  let data: any = [];
  if (userType === '1') {
    data.push('TEACHER_VIEW')
  } else {
    data.push('STUDENT_VIEW')
  }
  return data || [];
});
